package yu.zhou.njupt.importdata;

import java.util.Properties;

import org.apache.commons.lang3.StringUtils;

import yu.zhou.njupt.importdata.entity.enumtype.CreateTable;
import yu.zhou.njupt.importdata.entity.enumtype.DoTruncate;
import yu.zhou.njupt.importdata.entity.enumtype.NewImport;
import yu.zhou.njupt.importdata.worker.Worker;

public class Main {
    
    public static void main(String[] args) throws Exception {
    	Properties props = new Properties();

        props.load(Worker.class.getClassLoader().getResourceAsStream("config.properties"));
        
        String imports[] = StringUtils.split(props.getProperty("import"), ';');
        
        for (String str : imports) {
            String[] params = StringUtils.split(str, ',');
            Worker worker = new Worker(
            		params[0],
            		params[1].equals("1") ? DoTruncate.TRUE : DoTruncate.FALSE,
            		params[2].equals("1") ? NewImport.TRUE : NewImport.FALSE,
            	    params[3].equals("1") ? CreateTable.TRUE : CreateTable.FALSE,
            		Integer.valueOf(params[4])   
            		);
            worker.work();
		}
    }

}